<template>
  <!-- 顶部广告推荐 -->
  <div class="topad" v-if="topad" :style="{backgroundImage: 'url('+topad.imgUrl+')'}">
    <span @click="topad=null" class="iconfont off-font">&#xe8e7;</span>
  </div>
  <div class="main-container">
    <!-- 顶部通栏 -->
    <VmNavbar />
    <!-- 头部区域 -->
    <VmHeader />
    <!-- 首页主体部分 -->
    <HomePart />
    <!-- 底部区域 -->
    <footer >
      <ul class="part1 container">
        <li>
          <a href="https://www.vmall.com/help/faq-934.html">
            <i class="iconfont">&#xe615;</i>
            <p>百强企业 品质保证</p>
          </a>
        </li>
        <li>
          <a href="https://www.vmall.com/help/faq-834.html" >
            <i class="iconfont">&#xe89e;</i>
            <p>7天退货 15退换</p>
          </a>
        </li>
        <li>
          <a href="https://www.vmall.com/help/faq-4367.html">
            <i class="iconfont">&#xe89e;</i>
            <p>48元起免运费</p>
          </a>
        </li>
        <li>
          <a href="https://consumer.huawei.com/cn/support/service-center/">
            <i class="iconfont">&#xe683;</i>
            <p>2000家服务店 全国联保</p>
          </a>
        </li>
      </ul>
      <el-divider style="width: 1200px;"/>
      <div class="part2 container">
        <h1 class="font1">联系我们</h1>
        <h2>对华为产品、技术支持、合作等有任何问题，请通过这些渠道与我们联系</h2>
        <a href="https://www.huawei.com/cn/contact-us">了解更多</a>
        <h3>社交媒体关注</h3>
        <div class="icons">
          <a href="javascript:;">
            <i class="wx iconfont">
              &#xe601;
              <img src="@/assets/images/QR_公众号.jpg">
            </i>
          </a>
          <a target="_blank" href="https://www.toutiao.com/c/user/token/MS4wLjABAAAAs8rht0TsBhARnVJBDm-irbJ_rFdayHddfMoxtv40ZDw/?#mid=52586950033">
            <i class="iconfont">
              &#xe622;
            </i>
          </a>
          <a target="_blank" href="https://weibo.com/shophuawei">
            <i class="iconfont">
              &#xe65a;
            </i>
          </a>
          <a target="_blank" href="https://author.baidu.com/home/1587993495688621">
            <i class="iconfont">
              &#xe602;
            </i>
          </a>
        </div>
      </div>
      <b>2022华为技术有限公司 | &nbsp;&nbsp;&nbsp;粤A2-20044005号 | 
        &nbsp;&nbsp;&nbsp;粤公网安备44030702002388号</b>
    </footer>
  </div>
</template>

<script>
import { ref, watch } from 'vue'
import { getTopad } from '@/api/home'
import VmNavbar from '@/components/vm-navbar'
import VmHeader from '@/components/vm-header'
import HomePart from './home'
import { ElDivider } from 'element-plus'

export default {
  name: 'LayoutPage',
  components: { VmNavbar, VmHeader, HomePart, ElDivider },
  setup () {
    const topad = ref(null)
    const requestNum = ref(0)
    const showFlag = ref(false)
    
    const requestFn = data => {
      topad.value = data.result
    }
    const errFn = err => {
      console.log(err)
      console.log('当前topad:' + topad.value)
      console.log('当前requestNum:' + requestNum.value)
      console.log('当前showFlag:'+ showFlag.value)
      if (requestNum.value < 10) requestNum.value++
    }
    getTopad().then(requestFn).catch(errFn)
    watch(requestNum, () => { getTopad().then(requestFn).catch(errFn) })

    return { topad }
  }
}
</script>

<style lang="scss" scoped>
.topad {
    width: 100%;
    height: 90px;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center center;
    position: relative;
    cursor: pointer;
}
.off-font {
    font-family: "iconfont" !important;
    font-size: 20px;
    display: block;
    position: absolute;
    right: 10%;
    top: 10%;
    color: gray;
    &:hover {
        color: #a1afc9;
    }
}
.main-container {
  background-color: #f6f6f6;
}
footer {
  background: #fff;
  margin-top: -270px;
  padding-top: 30px;
  height: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  .part1 {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    li {
      a {
        display: flex;
        flex-direction: row;
        i {
          margin-right: 15px;
          font-size: 20px;
        }
        p {
          font-size: 16px;
          font-weight: 420;
          line-height: 30px;
        }
      }
      margin-right: 10%;
    }
  }
  .part2 {
    height: 800px;
    background: url('@/assets/images/联系我们.jpeg') no-repeat center;
    background-size: cover;
    color: #fff;
    text-align: center;
    h1 {
      font-size: 36px;
      
      margin-top: 30px;
    }
    h2 {
      margin: 50px 0;
      font-size: 30px;
    }
    h3 {
      margin: 50px 0;
      font-size: 24px;
      color: #c3d7df;
    }
    a {
      border: 1px solid white;
      display: inline-block;
      color: white;
      width: 200px;
      height: 50px;
      line-height: 50px;
      padding-left: 20px;
      padding-right: 20px;
      font-size: 30px;
      &:hover {
        background: #c02c38;
      }
    }
  }
  b {
      font-size: 18px;
      color: #5e616d;
  }
  .icons {
    display: flex;
    align-items: center;
    width: 1000px;
    margin: 0 auto;
    a {
      display: inline;
      padding: 0;
      border: none;
      margin-right: 8%;
      &:hover {
        background: none;
      }
      &:last-child {
        margin: 0;
      }
    }
    i {
      font-size: 60px;
    }
    .wx {
      position: relative;
      &:hover {
        img {
          display: block;
          transform: scale(2);
        }
      }
      img {
        display: none;
        position: absolute;
        bottom: -80px;
        left: 0;
      }
    }
  }
}
</style>>
